package com.gjy.redis.lua;

import com.gjy.redis.util.RedissonUtil;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;

/**
 * @author gjy
 * @version 1.0
 * @since 2024-05-25 00:37:27
 */
public class BloomLuaTest {

    private static final Logger log = LoggerFactory.getLogger(BloomLuaTest.class);
    private final Jedis jedis = RedissonUtil.jedisBasic();

    @Test
    public void test4() {
        String s = jedis.scriptLoad("return redis.call(\"bf.mexists\", KEYS[1], unpack(ARGV))");
        log.info("mexists: {}", s);
    }

    @Test
    public void test3() {
        String s = jedis.scriptLoad("return redis.call(\"bf.madd\", KEYS[1], unpack(ARGV))");
        log.info("madd: {}", s);
    }

    @Test
    public void test2() {
        String s = jedis.scriptLoad("return redis.call(\"bf.add\", KEYS[1], ARGV[1])");
        log.info("add: {}", s);
    }

    @Test
    public void test1() {
        String s = jedis.scriptLoad("return redis.call(\"bf.exists\", KEYS[1], ARGV[1])");
        log.info("exists: {}", s); // d88cfa8b2906ac9ef4ee09e0b3c0a7815b102813
    }

}
